﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CooliteExamples.Core.Extensions
{
    public static class StringExtensions
    {
        public static int AsInt(this string s)
        {
            int value;
            return !int.TryParse(s, out value) ? int.MinValue : value;
        }

        public static int AsInt(this string s, int defaultValue)
        {
            int value = s.AsInt();
            return value == int.MinValue ? defaultValue : value;
        }
    }
}
